package 课程设计;

import java.util.Scanner;

public class Testtime {
    public final static int INFINITY=0;
    public static void main(String[] args) {

        int[][] matrix = {{INFINITY,60,100,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY},
                {60,INFINITY,50,100,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY},
                {100,50,INFINITY,120,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY},
                { INFINITY,100,120,INFINITY,90,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY},
                {INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,110,INFINITY,INFINITY,INFINITY,INFINITY},
                {INFINITY,INFINITY,INFINITY,INFINITY,110,INFINITY,80,INFINITY,INFINITY,INFINITY},
                {INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY	,160,INFINITY,INFINITY},
                {INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,160,INFINITY,70,INFINITY},
                {INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,120},
                {INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,120,INFINITY}};
        int[][] matrix1 = {{INFINITY,60,100,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY},
                {60,INFINITY,50,100,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY},
                {100,50,INFINITY,120,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY},
                { INFINITY,100,120,INFINITY,90,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY},
                {INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,110,INFINITY,INFINITY,INFINITY,INFINITY},
                {INFINITY,INFINITY,INFINITY,INFINITY,110,INFINITY,80,INFINITY,INFINITY,INFINITY},
                {INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY	,160,INFINITY,INFINITY},
                {INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,160,INFINITY,70,INFINITY},
                {INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,120},
                {INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,120,INFINITY}};
        int[][] path = new int[10][10];
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                path[i][j] = j;
            }
        }
        int start,end;
        System.out.println("提示：0至9分别对应城市合肥，北京，上海，重庆，广州，南京，深圳，桂林，昆明，西安，输入的起点和终点用数字代表。");
        System.out.println("请分别输入起始点和终点：");
        Scanner sc = new Scanner(System.in);
        start=sc.nextInt();
        end=sc.nextInt();
        Road road = new Road();
        //初始路径
        road.showArray(path);
        //初始邻接矩阵
        road.showArray(matrix);
        road.findFloydRoad(matrix, path);
        //计算过后的路径
        road.showArray(path);
//        计算过后的距离
        road.showArray(matrix);
        //挑一对节点，输出路径
        System.out.println(road.findTheRoad(path, start, end).toString().replace("0","合肥")
                .replace("1","北京").replace("2","上海").replace("3","重庆")
                .replace("4","广州").replace("5","南京").replace("6","深圳")
                .replace("7","桂林").replace("8","昆明").replace("9","西安")

        );
        if(matrix1[start][end]==0){
            System.out.println("无该航班");
        }else
            System.out.println("总飞行时间为："+matrix1[start][end]+"分钟");


    }
}

